package topcoder.srm589;

import java.util.Collections;
import java.util.TreeMap;

public class GooseTattarrattatDiv2 {
	public int getmin(String S) {
		TreeMap<Character, Integer> wmap = new TreeMap<Character, Integer>();

		for (int i = 0; i < S.length(); i++) {
			Character c = S.charAt(i);
			Integer cnt = wmap.get(c);
			if (cnt == null)
				cnt = 0;
			cnt++;
			wmap.put(c, cnt);
		}

		int max = Collections.max(wmap.values());
		return S.length() - max;
	}

	public static void main(String[] args) {
		GooseTattarrattatDiv2 gt = new GooseTattarrattatDiv2();
		
		String S = "xrepayuyubctwtykrauccnquqfuqvccuaakylwlcjuyhyammag";
		
		System.out.println(gt.getmin(S));

	}

}
